package com.app.service.impl;

import com.app.mapper.PersonFamilyMapper;
import com.app.mapper.PersonResumeMapper;
import com.app.model.PersonFamilyModel;
import com.app.model.PersonResumeModel;
import com.app.service.PersonFamilyService;
import com.app.service.PersonResumeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Primary
public class PersonFamilyServiceImpl implements PersonFamilyService {
   @Autowired
    PersonFamilyMapper personFamilyMapper;


    @Override
    public List<PersonFamilyModel> getFamilyList(int personId) {
        QueryWrapper<PersonFamilyModel> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("id","person_id","appellation","member_name","birthday","zzmm","phone","unit","create_time","update_time")
                .eq("person_id",personId);
        List<PersonFamilyModel> familyModelList = personFamilyMapper.selectList(queryWrapper);
        return familyModelList;
    }

    @Override
    public List<PersonFamilyModel> listExport(Integer personId) {
        QueryWrapper<PersonFamilyModel> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("id","person_id","appellation","member_name","birthday","zzmm","phone","unit","create_time","update_time").eq("person_id",personId);
        List<PersonFamilyModel> familyModelList = personFamilyMapper.selectList(queryWrapper);
        return familyModelList;
    }

    @Override
    public void update(PersonFamilyModel model) {
        personFamilyMapper.updateById(model);
    }

    @Override
    public void insert(PersonFamilyModel model) {
        personFamilyMapper.insert(model);
    }

    @Override
    public void delete(int id) {
        personFamilyMapper.deleteById(id);
    }

    @Override
    public PersonFamilyModel getById(Integer id) {
        return personFamilyMapper.selectById(id);
    }
}
